-
Notifications
You must be signed in to change notification settings - Fork 598
[client-v2, jdbc-v2] Support for Time and Time64 #2487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other comments (8)
- clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseDataType.java (243-244) The Time and Time64 types are defined with LocalDateTime.class as their object type, but the mapping in dataTypeClassMap() doesn't include LocalDateTime. For consistency with other date/time types like DateTime and DateTime64, consider adding LocalDateTime and possibly ZonedDateTime to the mapping.
- clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseDataType.java (243-244) There's an inconsistency in the supported types between Time and Time64. Time64 supports BigInteger but Time doesn't. If Time64 is a higher precision version of Time, consider either adding BigInteger support to Time as well or documenting why only Time64 supports BigInteger.
- clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseDataType.java (131-132) The Time and Time64 types are defined with LocalDateTime.class as their object type. If these types represent only time values without date components, consider using LocalTime.class instead. If they do include date components, a comment explaining this would be helpful.
- client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java (183-183) The implementation for Time64 returns a BigInteger while Time returns a Long. This inconsistency might cause issues for callers expecting the same type. Consider either documenting this difference or making the return types consistent.
- client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/MapBackedRecord.java (133-134) The implementation for Time type assumes the value is stored as a long that can be directly converted to epoch seconds. Consider checking the actual type of the stored value before conversion, as other time-related types in this method use direct casting rather than going through getLong().
-
client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java (654-656)
The test is using a hardcoded string value for the Time64 test assertion. Consider calculating this value dynamically to make the test more robust against implementation changes:
new String[]{ String.valueOf(DataTypeUtils.toNanoseconds(maxTime64)) });
- client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java (659-662) The implementation for serializing Instant to Time64 combines seconds and nanos by shifting seconds left by 32 bits and adding nanos. This approach might not match ClickHouse's Time64 internal representation, which typically stores time as nanoseconds since midnight. Consider verifying this implementation against ClickHouse's expected format.
- client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java (554-556) The Time data type case only converts values to Integer. Consider adding support for more time-related types like LocalTime or java.sql.Time, which would make the API more flexible.
💡 To request another review, post a new comment with "/windsurf-review".
case Time: | ||
case Time64: | ||
return readValue(colName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Time/Time64 types, the code assumes readValue()
returns an Instant object. Is this guaranteed by the implementation? If not, there might be a ClassCastException when handling these types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point! Will verify.
client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java
Show resolved
Hide resolved
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java
Fixed
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java
Fixed
Show fixed
Hide fixed
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java
Fixed
Show fixed
Hide fixed
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java
Fixed
Show fixed
Hide fixed
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java
Fixed
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Have we tested with DBeaver or any other external tool?
Thank you @mzitnik ! I need to add more tests for JDBC part then will test with UI. |
|
Summary
Closes #2460
Checklist
Delete items not relevant to your PR: